package com.ep.modules.app.controller;

import com.ep.common.annotation.SysLog;
import com.ep.common.utils.PageUtils;
import com.ep.common.utils.R;
import com.ep.common.validator.ValidatorUtils;
import com.ep.modules.app.entity.AppCustomers;
import com.ep.modules.app.service.AppCustomersService;
import java.util.Map;
import org.springframework.beans.factory.annotation.*;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/app/customers")
public class AppCustomersController {
    @Autowired
    private AppCustomersService appCustomersService;

    @GetMapping("/list")
    public R list(Map<String, Object> params) {
        PageUtils page = appCustomersService.queryPage(params);
        return R.ok().put("page", page);
    }

    @GetMapping("/info/{id}")
    public R info(@PathVariable Long id) {
        AppCustomers appcustomers = appCustomersService.getById(id);
        return R.ok().put("appcustomers", appcustomers);
    }

    @SysLog("保存AppCustomers")
    @PostMapping("/save")
    public R save(@RequestBody AppCustomers appcustomers) {
        ValidatorUtils.validateEntity(appcustomers);
        appCustomersService.save(appcustomers);
        return R.ok();
    }

    @SysLog("修改AppCustomers")
    @PostMapping("/update")
    public R update(@RequestBody AppCustomers appcustomers) {
        ValidatorUtils.validateEntity(appcustomers);
        appCustomersService.update(appcustomers);
        return R.ok();
    }

    @SysLog("删除AppCustomers")
    @PostMapping("/delete")
    public R delete(@RequestBody Long[] ids) {
        appCustomersService.deleteBatch(ids);
        return R.ok();
    }
}